﻿
@model IEnumerable<Student>

@{
    ViewData["Title"] = "学生信息列表";

    
}

<table>
    <thead>
        <tr>
            <th>ID</th>
            <th>名字</th>
            <th>主修科目名称</th>
            <th>操作</th>
        </tr>
    </thead>
    <tbody>
        @foreach (var student in Model)
        {
            var photoPath = "~/images/" + (student.photopath ?? "timg.jpg");

            <tr>
                <td>
                    @student.Id
                </td>
                <td>
                    @student.Name
                </td>
                <td>
                    @**asp-append-version="true",去除缓存*@
                    <img src="@photoPath" asp-append-version="true" width="100" height="100" />
                </td>
                <td>
                    @student.ClassName
                </td>
                <td>
                    @* 以前mvc5的写法 *@
                    @*@Html.ActionLink("查看", "Details", new { id = student.Id })
                    <a href="@Url.Action("Details","Home",new { id=student.Id })">查看</a>*@
                    @* 最原始的写法 *@
                    @*<a href="/Home/Details/@student.Id">查看</a>*@

                    @*tagHelp写法**@
                    <a asp-controller="home" asp-action="details" asp-route-id="@student.Id" >查看</a>
                    <a asp-controller="home" asp-action="edit" asp-route-id="@student.Id" >编辑</a>
                </td>
            </tr>
        }
    </tbody>
</table>